package testing.src.vineet.java.code.linklist;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ListTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		List<Integer> ml = new MyLinkList<Integer>();
		while(true)
		{
			System.out.println("############## This is link List Implementation #################");
			System.out.println("Press 1 for add a node");
			System.out.println("Press 2 for delete a node");
			System.out.println("Press 3 for print");
			System.out.println("Press 0 for exit");
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int input = 0 ;
			try {
				String readInput = br.readLine();
				input = Integer.parseInt(readInput);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				System.out.println("############## exception occures ################# \n" + e.getMessage());
				input = 0 ;
			}
			catch(NumberFormatException nfe)
			{
				// TODO Auto-generated catch block
				System.out.println("############## exception occures ################# \n" + nfe.getMessage());
				input = 0 ;
			}
			if(input == 0)
			{
				break ;
			}
			else
			{
				switch(input)
				{
					case 1:
						System.out.println("Please enter a value");
						int valu = 0 ;
						try {
							String val = br.readLine();
							valu = Integer.parseInt(val);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							System.out.println("############## exception occures ################# \n" + e.getMessage());
						}
						ml.add(valu);
						break;
					case 2:
						System.out.println("Please enter a value");
						valu = 0 ;
						try {
							String val = br.readLine();
							valu = Integer.parseInt(val);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							System.out.println("############## exception occures ################# \n" + e.getMessage());
						}
						ml.delete(valu);
						break ;
					case 3:
						ml.print();
						break;
				}
			}
		}
	}
}
